﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using Common.Utilities;
using Common.Utilities.Dispatcher;

namespace Workflows.Components.SchemaUtil
{
    [Serializable]
    public class CLRScripterInstruction:InstructionBase 
    {
        #region props
        private string _DbServer;
        /// <summary></summary>
        public string DbServer
        {
            get
            {
                return this._DbServer;
            }
            set
            {
                this._DbServer = value;
            }
        }

        private AuthenticationType _AuthMethod;
        /// <summary></summary>
        public AuthenticationType AuthMethod
        {
            get
            {
                return this._AuthMethod;
            }
            set
            {
                this._AuthMethod = value;
            }
        }

        private string _UserName;
        /// <summary></summary>
        public string UserName
        {
            get
            {
                return this._UserName;
            }
            set
            {
                this._UserName = value;
            }
        }

        private string _Password;
        /// <summary></summary>
        public string Password
        {
            get
            {
                return this._Password;
            }
            set
            {
                this._Password = value;
            }
        }

        private string _DatabaseName;
        /// <summary></summary>
        public string DatabaseName
        {
            get
            {
                return this._DatabaseName;
            }
            set
            {
                this._DatabaseName = value;
            }
        }

        private string _CLRAssemblyName;
        /// <summary></summary>
        public string CLRAssemblyName
        {
            get
            {
                return this._CLRAssemblyName;
            }
            set
            {
                this._CLRAssemblyName = value;
            }
        }
        #endregion

        #region ctor
        public CLRScripterInstruction(Guid componentID, Guid jobTicketID)
            :base(componentID,jobTicketID)
        {
            this._DbServer = "localhost";
            this._AuthMethod = AuthenticationType.WindowsAuthentication;
            this._UserName = string.Empty;
            this._Password = string.Empty;
            this._DatabaseName = string.Empty;
            this._CLRAssemblyName = string.Empty;
        }

        /// <summary>
        /// constructor, all derived class must call default constructor 
        /// to initialize default settings.
        /// </summary>
        public CLRScripterInstruction(Guid componentID, Guid jobTicketID, 
            string dbServer, AuthenticationType authType, 
            string userName, string password, string dbName, 
            string clrAssemblyName)
            : base(componentID, jobTicketID)
        {
            this._DbServer = dbServer;
            this._AuthMethod = authType;
            this._UserName = userName;
            this._Password = password;
            this._DatabaseName = dbName;
            this._CLRAssemblyName = clrAssemblyName;
        }
        #endregion

        #region Overrides of InstructionBase

        /// <summary>
        /// serialize settings to xml
        /// the function below is mainly for storing into database as serialized form instead of string
        /// </summary>
        public override XmlNode Serialize(ref XmlDocument xDoc, ref XmlNode parentNode)
        {
            throw new System.NotImplementedException();
        }

        /// <summary>
        /// instantiated from xml
        /// "&lt;Instructions&gt;&lt;Instruction&gt;&lt;/Instruction&gt;&lt;/Instruction&gt;", must
        /// instantiate from first child of root node
        /// </summary>
        public override InstructionBase Instantiate(XmlNode xNode)
        {
            throw new System.NotImplementedException();
        }

        #endregion
    }
}
